package cn.nubia.admin.application.bean;

import cn.nubia.admin.sysconfig.bean.CategoryConstruct;
import cn.nubia.admin.common.constant.PicSizeEnum;
import cn.nubia.admin.common.utils.BeanUtils;
import cn.nubia.admin.file.bean.Upload;
import org.hibernate.validator.constraints.NotEmpty;

import java.io.File;
import java.io.Serializable;
import java.util.List;

/**
 * Created by justin on 15/7/15.
 */
public class SoftVO implements Serializable {

    private static final long serialVersionUID = -8244661101951482489L;

    private String icon512Url;
    private String icon125Url;
    private String icon114Url;
    private String icon62Url;

    private Integer softId;//软件id
    @NotEmpty(message = "{soft.softName.null}")
    private String softName;//软件名称
    private Integer categoryId;//分类id
    private String categoryName;
    private Integer categoryId2;//分类id
    private Integer categoryId3;//分类id
    private Integer categoryParentId;//分类父id
    @NotEmpty(message = "{soft.packageName.null}")
    private String packageName;//包名（软件标识符）
    private Integer sysStarsEnable;//是否开启系统星级
    private Float sysStars;//系统星级（0.5-5）
    private Float commentStars;//评论星级（0.5-5）
    private Integer isAccredit;//是否授权（1-授权 0-未授权）
    private Integer isOfficial;//是否官方（1-官方 0-非官方）
    private String developerName;//开发者名称
    private String developerPhone;//开发者手机/电话
    private String developerEmail;//开发者邮箱
    private String developerSite;//开发者网站
    private String summary;//软件简介
    private String description;//软件详细内容
    private String seo;//搜索关键词（用空格隔开）
    private Integer lastSoftItemId;//最新版本的软件项目id，未上架用0
    private Integer lastPublishTime;//最新版本的软件上架时间
    private Integer isDelete;//是否删除（1:删除  0: 正常）

    private Integer softItemId;
    private String itemName;//软件具体名称
    private Integer versionCode;//版本号
    private String versionName;//版本名称
    private Integer isLastVersion;//是否最新版本（1-最新 0-不是最新）
    private String deviceTypeList;//支持的设备类型
    private String iconUrl;//图标路径
    private String fileUrl;//文件路径
    private Integer fileSize;//软件大小（字节）
    private String fileMD5;
    private String signature;//软件签名--IG
    private Integer createTime;
    private Integer vdownloadNumber;//该版本总下载量
    private String updateDescription;//版本更新介绍
    private Integer lastModifyTime;
    private Integer publishTime;
    private Integer downloadNumber;//该版本总下载量
    private Integer state;//软件状态（-1-删除  0-待审核 1-已保存  3-上架 4-审核未通过 5-已下架 6-隐藏）
    private Integer minFirewareId;//最小平台固件
    private Integer maxFirewareId;//最大平台固件
    private Integer adState;//是否含广告（0-无广告 1-有广告 2-含恶意广告）
    private Integer safeState;//安全级别（0-不安全 1-安全 2-病毒/木马软件）
    private Integer resolution;//分辨率尺寸值
    private String qrCode;//二维码图片路径
    private Integer payType;//付费方式（0-免费 1-付费 2-限时免费）
    private Float payPrice;//付费价格
    private Integer firstPublish;//是否首发（0-否 1-是）
    private Integer softSrc;//'软件来源',---nb-dict-field
    private String softSrcCode;//从其他系统导入的原软件编号',--ig
    private Integer createAdminId;//添加软件的管理员id
    private String createAdminName;//创建人的管理员名称
    private Integer checkAdminId;//审核软件的管理员id
    private String checkAdminName;//审核软件的管理员名称
    private String checkReason;//审核原因备注
    private Integer language;// '语言id',---nb-dict-field
    private String permission;//软件拥有的执行权限
    private Integer prePublishTime;// '预发布时间',--ig
    private Integer checkTime;//审核时间
    private String adIconUrl;//广告图标地址
    private String adThumbUrl;

    private List<String> screenshotUrl;

    private List<Integer> screenshotId;

    private List<ScreenShot> screenShots;

    private Integer submitType;//（-1-删除  0-待审核 1-已保存  3-上架 4-审核未通过 5-已下架 6-隐藏）

    private String refererUrl;

    private String resolutionShow;

    private Integer fromType;

    private String minFirewareName;//最小平台固件

    private String maxFirewareName;//最大平台固件

    public void initFromSoftInfo(Soft soft) {
        BeanUtils.copyProperties(soft, this);
        this.setSoftId(soft.getId());
    }

    public void initCategory(CategoryConstruct categoryConstruct) {
        if(categoryConstruct!=null){
            this.setCategoryId(categoryConstruct.getFisrtCategoryId());
            this.setCategoryId2(categoryConstruct.getSecCategoryId());
            this.setCategoryId3(categoryConstruct.getThirdCategoryId());
        }
    }

    public Soft initSoftInfo() {
        Soft soft = new Soft();
        BeanUtils.copyProperties(this, soft);
        soft.setId(this.getSoftId());
        if(this.getCategoryId3()!=null&&this.getCategoryId3()>0){
            soft.setCategoryId(this.getCategoryId3());
            soft.setCategoryParentId(this.getCategoryId2());
        }else{
            if(this.getCategoryId2()!=null&&this.getCategoryId2()>0){
                soft.setCategoryId(this.getCategoryId2());
                soft.setCategoryParentId(this.getCategoryId());
            }else{
                soft.setCategoryId(this.getCategoryId());
            }
        }
        return soft;
    }

    public SoftItem initSoftItem(){
        SoftItem softItem = new SoftItem();
        BeanUtils.copyProperties(this, softItem);
        softItem.setId(this.getSoftItemId());
        softItem.setState(this.getSubmitType());
        return softItem;
    }

    public String getIcon512Url() {
        return icon512Url;
    }

    public void setIcon512Url(String icon512Url) {
        this.icon512Url = icon512Url;
    }

    public String getIcon125Url() {
        return icon125Url;
    }

    public void setIcon125Url(String icon125Url) {
        this.icon125Url = icon125Url;
    }

    public String getIcon114Url() {
        return icon114Url;
    }

    public void setIcon114Url(String icon114Url) {
        this.icon114Url = icon114Url;
    }

    public String getIcon62Url() {
        return icon62Url;
    }

    public void setIcon62Url(String icon62Url) {
        this.icon62Url = icon62Url;
    }

    public Integer getSoftId() {
        return softId;
    }

    public void setSoftId(Integer softId) {
        this.softId = softId;
    }

    public String getSoftName() {
        return softName;
    }

    public void setSoftName(String softName) {
        this.softName = softName;
    }

    public Integer getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Integer categoryId) {
        this.categoryId = categoryId;
    }

    public Integer getCategoryId2() {
        return categoryId2;
    }

    public void setCategoryId2(Integer categoryId2) {
        this.categoryId2 = categoryId2;
    }

    public Integer getCategoryId3() {
        return categoryId3;
    }

    public void setCategoryId3(Integer categoryId3) {
        this.categoryId3 = categoryId3;
    }

    public Integer getCategoryParentId() {
        return categoryParentId;
    }

    public void setCategoryParentId(Integer categoryParentId) {
        this.categoryParentId = categoryParentId;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public Integer getSysStarsEnable() {
        return sysStarsEnable;
    }

    public void setSysStarsEnable(Integer sysStarsEnable) {
        this.sysStarsEnable = sysStarsEnable;
    }

    public Float getSysStars() {
        return sysStars;
    }

    public void setSysStars(Float sysStars) {
        this.sysStars = sysStars;
    }

    public Float getCommentStars() {
        return commentStars;
    }

    public void setCommentStars(Float commentStars) {
        this.commentStars = commentStars;
    }

    public Integer getIsAccredit() {
        return isAccredit;
    }

    public void setIsAccredit(Integer isAccredit) {
        this.isAccredit = isAccredit;
    }

    public Integer getIsOfficial() {
        return isOfficial;
    }

    public void setIsOfficial(Integer isOfficial) {
        this.isOfficial = isOfficial;
    }

    public String getDeveloperName() {
        return developerName;
    }

    public void setDeveloperName(String developerName) {
        this.developerName = developerName;
    }

    public String getDeveloperPhone() {
        return developerPhone;
    }

    public void setDeveloperPhone(String developerPhone) {
        this.developerPhone = developerPhone;
    }

    public String getDeveloperEmail() {
        return developerEmail;
    }

    public void setDeveloperEmail(String developerEmail) {
        this.developerEmail = developerEmail;
    }

    public String getDeveloperSite() {
        return developerSite;
    }

    public void setDeveloperSite(String developerSite) {
        this.developerSite = developerSite;
    }

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getSeo() {
        return seo;
    }

    public void setSeo(String seo) {
        this.seo = seo;
    }

    public Integer getLastSoftItemId() {
        return lastSoftItemId;
    }

    public void setLastSoftItemId(Integer lastSoftItemId) {
        this.lastSoftItemId = lastSoftItemId;
    }

    public Integer getLastPublishTime() {
        return lastPublishTime;
    }

    public void setLastPublishTime(Integer lastPublishTime) {
        this.lastPublishTime = lastPublishTime;
    }

    public Integer getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(Integer isDelete) {
        this.isDelete = isDelete;
    }

    public Integer getSoftItemId() {
        return softItemId;
    }

    public void setSoftItemId(Integer softItemId) {
        this.softItemId = softItemId;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public Integer getVersionCode() {
        return versionCode;
    }

    public void setVersionCode(Integer versionCode) {
        this.versionCode = versionCode;
    }

    public String getVersionName() {
        return versionName;
    }

    public void setVersionName(String versionName) {
        this.versionName = versionName;
    }

    public Integer getIsLastVersion() {
        return isLastVersion;
    }

    public void setIsLastVersion(Integer isLastVersion) {
        this.isLastVersion = isLastVersion;
    }

    public String getDeviceTypeList() {
        return deviceTypeList;
    }

    public void setDeviceTypeList(String deviceTypeList) {
        this.deviceTypeList = deviceTypeList;
    }

    public String getIconUrl() {
        return iconUrl;
    }

    public void setIconUrl(String iconUrl) {
        if(iconUrl!=null&&!"".equals(iconUrl)){
            this.iconUrl = iconUrl;
            int location = iconUrl.lastIndexOf(File.separator);
            if(location>0){
                String iconPath = iconUrl.substring(0, location);
                this.setIcon512Url(iconPath + File.separator + "icon" + Upload.FILE_DIV + PicSizeEnum.ICON_512.getSize() + ".png");
                this.setIcon125Url(iconPath + File.separator + "icon" +Upload.FILE_DIV + PicSizeEnum.ICON_125.getSize() + ".png");
                this.setIcon114Url(iconPath + File.separator + "icon" +Upload.FILE_DIV + PicSizeEnum.ICON_114.getSize() + ".png");
                this.setIcon62Url(iconPath + File.separator + "icon" +Upload.FILE_DIV + PicSizeEnum.ICON_62.getSize() + ".png");
            }
        }
    }

    public String getFileUrl() {
        return fileUrl;
    }

    public void setFileUrl(String fileUrl) {
        this.fileUrl = fileUrl;
    }

    public Integer getFileSize() {
        return fileSize;
    }

    public void setFileSize(Integer fileSize) {
        this.fileSize = fileSize;
    }

    public String getFileMD5() {
        return fileMD5;
    }

    public void setFileMD5(String fileMD5) {
        this.fileMD5 = fileMD5;
    }

    public String getSignature() {
        return signature;
    }

    public void setSignature(String signature) {
        this.signature = signature;
    }

    public Integer getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Integer createTime) {
        this.createTime = createTime;
    }

    public Integer getVdownloadNumber() {
        return vdownloadNumber;
    }

    public void setVdownloadNumber(Integer vdownloadNumber) {
        this.vdownloadNumber = vdownloadNumber;
    }

    public String getUpdateDescription() {
        return updateDescription;
    }

    public void setUpdateDescription(String updateDescription) {
        this.updateDescription = updateDescription;
    }

    public Integer getLastModifyTime() {
        return lastModifyTime;
    }

    public void setLastModifyTime(Integer lastModifyTime) {
        this.lastModifyTime = lastModifyTime;
    }

    public Integer getPublishTime() {
        return publishTime;
    }

    public void setPublishTime(Integer publishTime) {
        this.publishTime = publishTime;
    }

    public Integer getDownloadNumber() {
        return downloadNumber;
    }

    public void setDownloadNumber(Integer downloadNumber) {
        this.downloadNumber = downloadNumber;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Integer getMinFirewareId() {
        return minFirewareId;
    }

    public void setMinFirewareId(Integer minFirewareId) {
        this.minFirewareId = minFirewareId;
    }

    public Integer getMaxFirewareId() {
        return maxFirewareId;
    }

    public void setMaxFirewareId(Integer maxFirewareId) {
        this.maxFirewareId = maxFirewareId;
    }

    public Integer getAdState() {
        return adState;
    }

    public void setAdState(Integer adState) {
        this.adState = adState;
    }

    public Integer getSafeState() {
        return safeState;
    }

    public void setSafeState(Integer safeState) {
        this.safeState = safeState;
    }

    public Integer getResolution() {
        return resolution;
    }

    public void setResolution(Integer resolution) {
        this.resolution = resolution;
    }

    public String getQrCode() {
        return qrCode;
    }

    public void setQrCode(String qrCode) {
        this.qrCode = qrCode;
    }

    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    public Float getPayPrice() {
        return payPrice;
    }

    public void setPayPrice(Float payPrice) {
        this.payPrice = payPrice;
    }

    public Integer getFirstPublish() {
        return firstPublish;
    }

    public void setFirstPublish(Integer firstPublish) {
        this.firstPublish = firstPublish;
    }

    public Integer getSoftSrc() {
        return softSrc;
    }

    public void setSoftSrc(Integer softSrc) {
        this.softSrc = softSrc;
    }

    public String getSoftSrcCode() {
        return softSrcCode;
    }

    public void setSoftSrcCode(String softSrcCode) {
        this.softSrcCode = softSrcCode;
    }

    public Integer getCreateAdminId() {
        return createAdminId;
    }

    public void setCreateAdminId(Integer createAdminId) {
        this.createAdminId = createAdminId;
    }

    public String getCreateAdminName() {
        return createAdminName;
    }

    public void setCreateAdminName(String createAdminName) {
        this.createAdminName = createAdminName;
    }

    public Integer getCheckAdminId() {
        return checkAdminId;
    }

    public void setCheckAdminId(Integer checkAdminId) {
        this.checkAdminId = checkAdminId;
    }

    public String getCheckAdminName() {
        return checkAdminName;
    }

    public void setCheckAdminName(String checkAdminName) {
        this.checkAdminName = checkAdminName;
    }

    public String getCheckReason() {
        return checkReason;
    }

    public void setCheckReason(String checkReason) {
        this.checkReason = checkReason;
    }

    public Integer getLanguage() {
        return language;
    }

    public void setLanguage(Integer language) {
        this.language = language;
    }

    public String getPermission() {
        return permission;
    }

    public void setPermission(String permission) {
        this.permission = permission;
    }

    public Integer getPrePublishTime() {
        return prePublishTime;
    }

    public void setPrePublishTime(Integer prePublishTime) {
        this.prePublishTime = prePublishTime;
    }

    public Integer getCheckTime() {
        return checkTime;
    }

    public void setCheckTime(Integer checkTime) {
        this.checkTime = checkTime;
    }

    public String getAdIconUrl() {
        return adIconUrl;
    }

    public void setAdIconUrl(String adIconUrl) {
        this.adIconUrl = adIconUrl;
        if(adIconUrl!=null && adIconUrl!="") {
            int location = adIconUrl.lastIndexOf(File.separator);
            if(location>0){
                String adUrlPath = adIconUrl.substring(0, location);
                this.setAdThumbUrl(adUrlPath + File.separator + "adthumb.png");
            }
        }
    }

    public List<String> getScreenshotUrl() {
        return screenshotUrl;
    }

    public void setScreenshotUrl(List<String> screenshotUrl) {
        this.screenshotUrl = screenshotUrl;
    }

    public List<Integer> getScreenshotId() {
        return screenshotId;
    }

    public void setScreenshotId(List<Integer> screenshotId) {
        this.screenshotId = screenshotId;
    }

    public List<ScreenShot> getScreenShots() {
        return screenShots;
    }

    public void setScreenShots(List<ScreenShot> screenShots) {
        this.screenShots = screenShots;
    }

    public Integer getSubmitType() {
        return submitType;
    }

    public void setSubmitType(Integer submitType) {
        this.submitType = submitType;
    }

    public String getRefererUrl() {
        return refererUrl;
    }

    public void setRefererUrl(String refererUrl) {
        this.refererUrl = refererUrl;
    }

    public String getResolutionShow() {
        return resolutionShow;
    }

    public void setResolutionShow(String resolutionShow) {
        this.resolutionShow = resolutionShow;
    }

    public Integer getFromType() {
        return fromType;
    }

    public void setFromType(Integer fromType) {
        this.fromType = fromType;
    }

    public String getMinFirewareName() {
        return minFirewareName;
    }

    public void setMinFirewareName(String minFirewareName) {
        this.minFirewareName = minFirewareName;
    }

    public String getMaxFirewareName() {
        return maxFirewareName;
    }

    public void setMaxFirewareName(String maxFirewareName) {
        this.maxFirewareName = maxFirewareName;
    }

    public String getAdThumbUrl() {
        return adThumbUrl;
    }

    public void setAdThumbUrl(String adThumbUrl) {
        this.adThumbUrl = adThumbUrl;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }
}
